Technical Q&As


DV 05 - Determining Whether a Device Supports Asynchronous I/O (1-July-95)


Q How can we determine whether a device supports asynchronous I/O?

A The best way to determine if a SCSI device supports asynchronous I/O is to use Gestalt. Check the gestaltSCSI selector to see if the gestaltAsyncSCSI bit is set, as shown below:

#include <Gestalt.h>
Boolean CanDoAsyncSCSI(void)
{
  long response;
  OSErr err;

  err = Gestalt(gestaltSCSI, &response);
  if (err) return false;
  return (response & (1 << gestaltAsyncSCSI) );
}

There is no Gestalt test currently available for non-SCSI devices. You can assume that asynchronous calls to a driver will be handled correctly. If the driver is actually asynchronous, your completion routine is called when the I/O is finished. If the driver is not asynchronous, the driver returns and calls your completion routine when the I/O is finished.
For more information, see the SCSI Manager 4.3 chapter of Inside Macintosh:Devices and "Asynchronous routines on the Macintosh" in issue 13 of Develop.

Technical Q&As
Previous Question | Contents | Next Question